package com.tt.mymu.controller;

import com.tt.mymu.entity.Sub;
import com.tt.mymu.service.SubService;
import com.tt.mymu.utils.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("sub")
public class SubController {
    @Autowired
    private SubService subService;

    /**
     * 获取目录主数据
     * @return
     */
    @RequestMapping("getSubListById")
    public Result getSubListById(Integer menuId) {
        return subService.getSubListById(menuId);
    }

    /**
     * 获取所有目录信息
     * @return
     */
    @RequestMapping("getSubList")
    public Result getSubList() {
        return subService.getSubList();
    }

    /**
     * 添加目录信息
     * @return
     */
    @RequestMapping("addSub")
    public Result addSub(Sub sub) {
        return subService.addSub(sub);
    }

    /**
     * 更新目录信息
     * @return
     */
    @RequestMapping("updateSub")
    public Result updateSub(Sub sub) {
        return subService.updateSub(sub);
    }

    /**
     * 删除目录信息
     * @return
     */
    @RequestMapping("deleteSub")
    public Result deleteSub(Integer id) {
        return subService.deleteSub(id);
    }
}
